import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:hockey/support_files/assets.gen.dart';
import 'package:path/path.dart' as path;

part 'jzx_video_data.freezed.dart';
part 'jzx_video_data.g.dart';

@freezed
class JzxVideoData with _$JzxVideoData {
  const factory JzxVideoData({
    @Default('') String mediaType,
    @Default('') String mediaPath,
    @Default('') String thumbUrl,
    @Default('') String middleThumbUrl,
    @Default('') String mediaUrl,
  }) = _JzxVideoData;

  factory JzxVideoData.fromJson(Map<String, Object?> json) =>
      _$JzxVideoDataFromJson(json);
}

extension JzxVideoDataExt on JzxVideoData {
  /// 本地封面
  AssetGenImage get cover {
    return AssetGenImage(coverStr);
  }

  /// 本地封面地址
  String get coverStr {
    final name = path.basenameWithoutExtension(mediaPath);
    return 'assets/video/c$name.jpg';
  }
}
